<template>
	<view style="background-color: #fff;"></view>
</template>
<script>
	var wv; //计划创建的webview	
	export default {
		data() {
			return {
				ModuleTitle: '',
				pdfUrl: '',
				FormData: {
					EquipmentID: 0,
					EquipmentName: '',
					FWorkshopID: null,
					UserName: ''
				},
			};
		},
		onLoad(options) {
			var that = this
			uni.hideLoading();
			const {
				GuyueModule,
				UserInfo,
				appConfigInfo
			} = that.$store.state;
			const {
				MesBasicInfo
			} = GuyueModule;
			that.ModuleTitle = appConfigInfo.ActiveModule.ModuleName;
			const formDefaults = {
				FWorkshopID: MesBasicInfo.FWorkshopID,
				EquipmentID: MesBasicInfo.warehouse.EquipmentID,
				EquipmentName: MesBasicInfo.warehouse.EquipmentName,
				UserName: UserInfo.UserName,
			};
			that.assignFormData(that.FormData, formDefaults);
			console.log(that.Request.IPAgreement() + that.Request.serverIP());
			if (options.Dispatchitem) {
				const dispatchItem = JSON.parse(options.Dispatchitem);
				var DispatchUrl =
					'http://mes.hzyc.org.cn:18080/webroot/decision/view/report?viewlet=H64.0ZSMES%252F%25E6%25B3%25A8%25E5%25A1%2591%25E6%259C%25BA%25E5%258F%2582%25E6%2595%25B0%25E8%25AE%25B0%25E5%25BD%2595.cpt&ref_t=design&op=write&ref_c=dd07e504-fa43-4288-816c-5207c8cda7cc ' +
					'&EquipmentID=' + that.FormData.EquipmentID + '&MoldNum=' + dispatchItem.MoldNum + '&MoldID=' +
					dispatchItem.MoldID + '&ProductID=' + dispatchItem.ProductID + '&UserName=' + that.FormData.UserName +
					'&JobOrderID=' + dispatchItem.JobOrderID + '&TestMoldID=' + dispatchItem.TestMoldID
				// #ifdef APP-PLUS
				var statusBarHeight = uni.getSystemInfoSync().statusBarHeight
				wv = plus.webview.create("", "custom-webview", {
					plusrequire: "none", //禁止远程网页使用plus的API，有些使用mui制作的网页可能会监听plus.key，造成关闭页面混乱，可以通过这种方式禁止
					'uni-app': 'none', //不加载uni-app渲染层框架，避免样式冲突
					top: uni.getSystemInfoSync().statusBarHeight,
					bottom: uni.getSystemInfoSync().statusBarHeight,
					left: uni.getSystemInfoSync().statusBarHeight,
					right: uni.getSystemInfoSync().statusBarHeight,
					progress: {
						color: '#3c9cff'
					},
					scalable: true
				})
				wv.loadURL(DispatchUrl)
				var currentWebview = this.$scope
					.$getAppWebview();
				currentWebview.append(wv);
				// #endif
				return;
			}
		},
		onUnload() {
			uni.$emit('refreshList');
		},
		methods: {
			// 创建表单赋值工具函数
			assignFormData(target, defaults = {}) {
				var that = this;
				Object.keys(defaults).forEach(key => {
					target[key] = defaults[key];
				});
				that.$forceUpdate();
			},

		}
	}
</script>

<style lang="scss">
	@import "../css/index.css";
</style>